<?php

class PermissaoModel extends AppModel {

	protected $_tableName = "permissao";
	
	public function isValid($tipoPermissao, $controller, $action) {
		$response = parent::selectWhere("tipo_permissao_id='".$tipoPermissao."' AND controller='".$controller."' AND actions LIKE '%".$action."%' LIMIT 0,1");
		return ( count($response) == 1 );
	} 
	
	public function hasPermission($tipoPermissao, $controller) {
		$response = parent::selectWhere("tipo_permissao_id='".$tipoPermissao."' AND controller='".$controller."' AND actions='todas' LIMIT 0,1");
		return ( count($response) == 1 );
	}
	
}

?>